package com.zjc.utils;

import com.google.gson.Gson;
import com.google.gson.GsonBuilder;
import com.zjc.utils.collection.KeyLinkedBlockingQueue;
import com.zjc.utils.collection.KeyLinkedBlockingQueueValue;
import com.zjc.utils.date.DateUtils;
import lombok.Data;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;

import java.util.Random;

@Data
public class UtilsMain {

    private static final Logger logger = LoggerFactory.getLogger(UtilsMain.class);
    private static Gson gson = new GsonBuilder()
            .setDateFormat("yyyy-MM-dd HH:mm:ss")
            .create();


    public static void main(String[] args) {

        KeyLinkedBlockingQueue keyLinkedBlockingQueue = new KeyLinkedBlockingQueue(1000);

        for (int i = 0; i < 1000; i++) {

            KeyLinkedBlockingQueueValue value = new KeyLinkedBlockingQueueValue();
            value.setUniqueNo(new Random().nextInt(100) + "");
            value.setTime(DateUtils.getCurrentTimeStr());
            keyLinkedBlockingQueue.add(value);
            logger.info("添加元素：{}", gson.toJson(value));
        }
    }
}
